//如果有链接的点击事件
function on_click_msg(msg_id, msg_link) {
    var $this=$(this);
    RequestService("/online/message/updateReadStatusById", "post", {
        id: msg_id
    }, function(data) {
        if(data.success == true) {
            window.open(msg_link,"_blank");
        }
    }, false);
};
//login template
(function loginTemp(){
    var url = basePathOnline+"/home/js/commTemplate/loginTemp/loginTemp.js";
    var script = document.createElement('script');
    script.setAttribute('src', url);
    // 把script标签加入head，此时调用开始
    $(document.getElementsByTagName('head')[0]).prepend(script);
})();
$(function () {
    //==========================================================================================
    //document.domain="boxuegu.com"
    var headersIndex={
        nav:'<div class="header_left">' +
        '<a href="/index.html" class="hearder_logo">' +
        '<img src="/home/img/newLogo.png"/>'+
        '</a>' +
        '<div class="header_path clearfix">'+
        '<ul class="pathLeft clearfix">' +
        '<li class="path"><a href="'+basePathOnline+'">首页</a></li>' +
        '<li class="path"><a href="/class">片库</a></li>' +
        '<li class="path weike"><a href="javascript:void(0);">微课<span class="caret"></span></a>' +
        '<div class="pathLeft_subNav">'+
        '<a href="/course/class/classType/micro" target="_blank">精品微课</a>' +
        '<a href="/course/class/classType/free" target="_blank">免费微课</a>'+
        '</div>'+
        '</li>' +
        '<li class="path studycommunity"><a href="javascript:void(0);">友链<span class="caret"></span></a>' +
        '<div class="pathLeft_subNav">'+
        '<a href="'+basePathBlog+'" target="_blank">博客&emsp;&emsp;</a>'+
        '<a href="'+basePathShop+'" class="LearningCommunityList" target="_blank">商城&emsp;&emsp;</a>' +
        '<a href="'+basePathAPPDownload+'" class="LearningCommunityList" target="_blank">APP</a>' +
        '</div>'+
        '</li>' +
        '<li class="path path_ask"><a href="/ask" target="_blank">论坛</a></li>' +
        '</ul>'+
        '</div>'+
        '</div>'+
        '<div class="header_right">'+
        '<div class="searhInpt" id="searchInp">'+
        '<input  type="text"  id="searchTxt"/>' +
        '<div class="searchKeys"><span data-keyWords="谈判官">谈判官</span><span data-keyWords="烈火如歌">烈火如歌</span></div>'+
        '<button class="seachBtn" id="sy6"></button>'+
        '</div>' +
        '<a href="javascript:;" class="studentCenterBox" id="sy2" title="学习中心"><i class="iconfont icon-shu2"></i></a>'+
        '<div class="shoppingBox">'+
        '<a href="javascript:;" data-id="" class="shoppingCar" id="sy3" title="购物车"><i class="iconfont icon-gouwuche"></i></a>'+
        '<span class="shopping"><em>10</em></span>'+
        '</div>'+
            /*'<span class="lineBetween">|</span>'+*/
        '<div class="loginGroup">'+
        '<div class="login" style="display: none;">'+
        '<div class="dropdown" id="myDropdown">'+
        '<a href="javascript:;">' +
        '<div class="userPic">'+
        '<span class="messageCount"><em></em></span>'+
        '</div>'+
        '<span class="caret"></span>' +
        '</a>' +
        '<a data-id="mynews" id="wdxx"><i class="dotRed"></i>我的消息</a>' +
        '<a data-id="myorder" id="wddd">我的订单</a>' +
        '<a data-id="myduihuan" id="wdyhq">优惠券</a>' +
        '<a data-post="mypost">我的帖子</a>' +
        '<a data-id="mydata" id="grsz">个人设置</a>' +
        '<a data-exit="exit" id="aqtc">安全退出</a>'+
        '</div>'+
        '</div>'+
        '<div class="logout" style="display:none;">'+
        '<a class="btn-login btn-link" data-toggle="modal" data-target="#login" data-backdrop="static" id="sy4">登录</a>'+
        '<a class="btn-register btn-link" href="javascript:;" id="sy5">注册</a>'+
        '</div>'+
        '</div>'+
        '</div>',
        pinpai:'<div class="pinpai">'+
        '<p>'+
        '<span class="pinpaiLeft">零玖一旗下视频服务平台 <span class="shus" style="display:none;">|</span><a style="display:none; href="http://www.itheima.com" target="_blank">线下学院</a></span>'+
        //'<span class="pinpaiRight"><img src="/home/img/header/headerword.png" alt=""/></span>'+
        '</p>'+
        '</div>',
        oldStudent:'<div class="oldModal" id="old">'+
        '<div class="oldBody">'+
        '<img src="/home/img/duihuan/oldModal.png"/>'+
        '<span class="oldX">X</span>'+
        '<a class="oldBtn">立即前往</a>'+
        '</div>'+
        '</div>'+
        '<div id="oldModalBack"></div>',
        //职业路线
        VocationalRoute:'{{each careerPathListData as careerPathList}}'+
        '<li><a href="/vocationalRoute/?id={{careerPathList.id}}" class="hotClass">{{careerPathList.careerPathName}}</a></li>'+
        '{{/each}}'
    };
    //网站公告
    var webNotice='<div class="webSiteNotice" style="display:none;">'+
        '<div class="innerBox clearfix">'+
        '<i class="iconfont icon-laba xiaoxilaba"></i><span class="noticeInfo"></span><i class="iconfont icon-guanbi noticeClose"></i>'+
        '</div></div>';
    var slideNavIndex={
        /* 咨询中心*/
        consult_center:'<div class="consult_center">咨询中心</div>',
        <!--在线咨询和电话咨询-->
        online_consult:'<div class="online_consult">'+
        '<a href="http://q.url.cn/s/G85y4Xm?_type=wpa" id="bxgzxzx" target="_blank">'+
        '<em></em>' +
        '<p>在线咨询</p>' +
        '</a></div>',
        phone_consult:'<div class="phone_consult">'+
        '<em></em>' +
        '<div class="phone_consult_hover clearfix"><span class="phone_number">010-56288220</span><em></em></div>'+
        ' </div>',
        weixin:'<div class="sideWeixinBox">'+
        '<div class="sideWeixin">'+
        '<em></em>' +
        '<p>关注微信</p>'+
        '</div>'+
        '<div class="sideWeixinErma">'+
        '<img src="/home/img/sideWeixin.png" />'+
        '<p>关注服务号<br/>获取学习通知</p>'+
        '<div class="sideSanjiao">'+
        '<img src="/home/img/float_sanjiao.png" />'+
        '</div>'+
        '</div>'+
        '</div>',
        weibo:'<a class="sideWeiboBox" href="http://weibo.com/u/5999622644?refer_flag=1001030102_&amp;is_hot=1" target="_blank">' +
        '<div class="sideWeibo">'+
        '<em></em>' +
        '<p>关注微博</p>'+
        '</div>'+
        '<div class="sideWeiboErma">'+
        '<img src="/home/img/sideWeibopng.png" />'+
        '<p>关注微博</p>'+
        '<div class="sideSanjiao1">'+
        '<img src="/home/img/float_sanjiao.png" />'+
        '</div>'+
        '</div>'+
        '</a>',
        mobile:'<a class="mobileBox" href="/app/index.html" target="_blank">' +
        '<div class="sideWeibo">'+
        '<em></em>' +
        '<p>APP</p>'+
        '</div>'+
        '<div class="mobileErma">'+
        '<img src="/home/img/sidemobile.png" />'+
        '<p>APP</p>'+
        '<div class="sideSanjiao1">'+
        '<img src="/home/img/float_sanjiao.png" />'+
        '</div>'+
        '</div>'+
        '</a>',
        feedback:'<div class="feedback">'+
        '<a href="javascript:;" id="bxgyjfk">'+
        '<em></em>' +
        '<p>意见反馈</p>' +
        '</a></div>',

        <!--返回顶部-->
        h_top:'<div class="h_top" onclick="pageScroll();">' +
        '<span class="wrap">'+
        '<em class="row"></em>' +
        '<em class="word"></em>'+
        '</span></div>'
    }

    var header=$('<header class="clearfix"><div class="header_body"></div></header>');
    $(header).find(".header_body").before(template.compile(headersIndex.pinpai));
    $(header).find(".header_body").append(template.compile(headersIndex.nav));//首页头部
    /*$(header).find('.header_path').append(template.compile(headersIndex.navPath));//新版导航栏*/

    $("body").children(":first").before(header);
    // $(header).append(template.compile(headersIndex.login));
    $(header).append(template.compile(headersIndex.oldStudent));
    $(header).before(template.compile(webNotice));
    /*  $(header).append(template.compile(slideNavIndex.consult_center));*/
    $(header).find('.header_path').append("<div class='rightSide'><div class='zxCenter'></div></div>");
    $(".rightSide .zxCenter").append(template.compile(slideNavIndex.online_consult));
//  $(".rightSide .zxCenter").append(template.compile(slideNavIndex.phone_consult));
    $(".rightSide .zxCenter").append(template.compile(slideNavIndex.weixin));
    $(".rightSide .zxCenter").append(template.compile(slideNavIndex.weibo));
    $(".rightSide .zxCenter").append(template.compile(slideNavIndex.mobile));
    $(".rightSide .zxCenter").append(template.compile(slideNavIndex.feedback));

    $(".rightSide").append(template.compile(slideNavIndex.h_top));

    //导航职业路线
    RequestService("/careerPath/careerPathList","POST",{'_token': $("input[name='_token']").val()},function(data){
        if(data.success==true){
            $('#VocationalRoute').html(template.compile(headersIndex.VocationalRoute)({careerPathListData:data.resultObject}));//新版导航栏
            //配置导航栏路径
            $(".path a").each(function(){
                if($(this).text() == "学习空间"){
                    $(this).attr("href",basePathStudyzone+$(this).attr("href"));
                }else if($(this).text() == "论坛"){

                }else if($(this).text() == "社区"||$(this).text() == "职业路线"||$(this).text() == "微课"){

                }else{
                    if($(this).text()=="免费微课"||$(this).text()=="精品微课"){
                        $(this).click(function(){
                            sessionStorage.removeItem('directionId');
                            sessionStorage.removeItem('tagId');
                        })
                    }
                }
            });
        }
    })

    //右侧悬浮栏的位置
    /*  $(document).scroll(function(){
     var clientHeight=$(this).scrollTop()+156;
     if(clientHeight<=500){
     $(".rightSide").css({'top':'372px'});
     }else if(clientHeight>500){
     $(".rightSide").css({'top':clientHeight+'px'})
     }
     });*/
    $("#bxgzxzx").click(function(){
        eventClick("a","click");
    });
    //意见反馈
    $(".feedback").click(function(){
        RequestService("/online/user/isAlive","GET",null,function(data){
            if(!data.success){
                window.localStorage.myFeedback=1;
                window.localStorage.personcenter="idea";
                $('#login').modal('show');
            }else{
                window.localStorage.personcenter="idea";
                window.location.href="/web/html/personcenter.html";
            }
        })
    });

    $(".oldBtn").click(function(){
        window.localStorage.personcenter = "mydata";
        window.location.href = "/web/html/personcenter.html";
    });
    $(".oldX").click(function(){
        $("#oldModalBack").hide();
        $("#old").hide();
    });

    if(window.location.pathname.indexOf("index") != "-1" || window.location.pathname=="/"){
        //$("body").children(":first").after(header);
        $(".friendSee .friendSee-Body .closeSee").click(function(){
            $(".friendSee").remove();
        })
    }else{
        //$("body").children(":first").before(header);
        //$('#searchInp').hide()
    }
//==========================================================================================
    //侧边栏微信，微博
    $(".sideWeixinBox").hover(function(){
        $(".sideWeixinErma").css("display","block");
        $(".sideWeixinBox").css("backgroundColor","#eef3f8");
    },function(){
        $(".sideWeixinErma").css("display","none");
        $(".sideWeixinBox").css("backgroundColor","#fff");
    });
    $(".sideWeiboBox").hover(function(){
        $(".sideWeiboErma").css("display","block");
        $(".sideWeiboBox").css("backgroundColor","#eef3f8");
    },function(){
        $(".sideWeiboErma").css("display","none");
        $(".sideWeiboBox").css("backgroundColor","#fff");
    });
    $(".mobileBox").hover(function(){
        $(".mobileErma").css("display","block");
        $(".mobileBox").css("backgroundColor","#eef3f8");
    },function(){
        $(".mobileErma").css("display","none");
        $(".mobileBox").css("backgroundColor","#fff");
    });
    //网站公告
    RequestService("/online/message/findNewestNotice","GET",null,function(data){
        if(data.resultObject==null){
            $(".webSiteNotice").css("display","none");
        }else if(data.resultObject!=null && data.resultObject!=""){
            $(".webSiteNotice .noticeInfo").html(data.resultObject.notice_content);
            if(data.resultObject.infoType==1){
                $(".noticeClose").css("display","none");
            }else{
                $(".webSiteNotice a").attr("target","_blank");
            }
            if(window.localStorage.dontsee ==data.resultObject.id){
                $(".webSiteNotice").css("display","none");
            }else{
                $(".webSiteNotice").css("display","block");
                $(".webSiteNotice .noticeClose").click(function(){
                    window.localStorage.dontsee = data.resultObject.id;
                    $(".webSiteNotice").css("display","none");
                });
            }
        }
    });
    //学习中心
    $(".studentCenterBox").click(function(){
        RequestService("/online/user/isAlive","GET",null,function(data){
            if(!data.success){
                localStorage.myStudyCenter="1";
                $('#login').modal('show');
            }else{
                window.location.href="/web/html/myStudyCenter.html";
            }
        })
    });
    //购物车
    $(".shoppingBox .shoppingCar").click(function(){
        RequestService("/online/user/isAlive", "GET", null, function (data) {
            if(data.success==false){
                $("#login").modal("show");
            }else{
                window.location.href="/web/html/shoppingCart.html";
            }
        })
    });
    //消息提醒
    $(".messageBox .message").click(function(){
        RequestService("/online/user/isAlive", "GET", null, function (data) {
            if(data.success==false){
                $("#login").modal("show");
            }else{
                window.localStorage.personcenter = $(this).attr("data-id");
                window.location.href="/web/html/personcenter.html";
            }
        })
    });
//浏览器判断升级提示
    var browserUpgrade = '<div class="browserBody" style="display:none;">' +
        '<div class="bcgop"></div>' +
        '<div class="browserBody-text">' +
        '<p>您目前使用的浏览器可能无法实现最佳浏览效果，建议使用Chrome(谷歌)、Firefox(火狐)、Edge、IE9及IE9以上版本浏览器。</p>' +
        '<a href="/web/html/Download.html">立即升级</a>' +
        '<img src="/home/img/BWcolse.png"/>' +
        '</div>' +
        '</div>';
//浏览器判断

    function myBrowser(){
        var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
        var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
        var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
        var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
        var isSafari = userAgent.indexOf("Safari") > -1; //判断是否Safari浏览器
        var isChrome = userAgent.indexOf("Chrome") > -1; //判断是否谷歌浏览器
        var isQQ = userAgent.indexOf("QQBrowser") > -1 && userAgent.indexOf("Chrome") == -1; //QQ浏览器非极速模式
        if (isIE) {
            var IE5 = IE55 = IE6 = IE7 = IE8 = false;
            var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
            reIE.test(userAgent);
            var fIEVersion = parseFloat(RegExp["$1"]);
            IE55 = fIEVersion == 5.5;
            IE6 = fIEVersion == 6.0;
            IE7 = fIEVersion == 7.0;
            IE8 = fIEVersion == 8.0;
            IE9 = fIEVersion == 9.0;
            if (IE55) {
                return "IE55";
            }
            if (IE6) {
                return "IE6";
            }
            if (IE7) {
                return "IE7";
            }
            if (IE8) {
                return "IE8";
            }
            if (IE9) {
                return "IE9";
            }
        }else if(isQQ){
            return "QQ";
        }

    }//myBrowser() end


//==========================================================================================
    $("body").append(template.compile(browserUpgrade));


//以下是调用上面的函数
    if (myBrowser() == "IE55") {
        window.location.href = "/web/html/Download.html";
    }else if (myBrowser() == "IE6") {
        window.location.href = "/web/html/Download.html";
    }else if (myBrowser() == "IE7") {
        window.location.href = "/web/html/Download.html";
    }else if (myBrowser() == "IE8") {
        window.location.href = "/web/html/Download.html";
    }else if(myBrowser() == "IE9"){
        window.location.href = "/web/html/Download.html";
    }else if(myBrowser() == "QQ"){
        window.location.href = "/web/html/Download.html";
    }
    /*$(".browserBody .browserBody-text img").on("click",function(){
     $(".browserBody").css("display","none");
     });*/
    $(".cyinput1").on("input", function () {
        var val = $(this).val();
        if (val == "") {
            $(".cymyloginclose1").css("display", "none");
        } else {
            $(".cymyloginclose1").css("display", "block");
        }
        return false;
    });
    $(".cyinput2").on("input", function () {
        var logPass = $(this).val();
        if (logPass == "") {
            $(".cymyloginclose2").css("display", "none");
        } else {
            $(".cymyloginclose2").css("display", "block");
        }
        return false;
    });
    /*云课堂和博问答切换*/
//  $(".path a").on('click', function () {
//      $(this).addClass('select').siblings().removeClass('select');
//  })
    /*点击头像和用户名跳转到个人中心*/
//  $(".userPic,#dLabel").on('click', function () {
//      var id = "personcenter";
//      window.localStorage.personcenter = "myanswer";
//      location.href = "/web/html/personcenter.html";
//  });
    /*个人中心点击立即登录后，当前用户退出登录*/
    $(".pLogin").on("click", function () {
        $(".loginGroup .logout").css("display", "block");
        $(".loginGroup .login").css("display", "none");
    });

    var flag = false;
    function errorMessage(info) {
        flag = false;
        var errorReg = /[a-zA-z]+/g;
        if (errorReg.test(info)) {
            layer.alert("系统繁忙，请稍候再试!", {icon: 2});
            return flag = true;
        }
    }

    /*登录注册字体颜色和箭头方向的改变*/
    $("#myDropdown").hover(function () {
        $("#myDropdown").addClass("open");
//      $("#dLabel span:first-child").toggleClass("select");
//      $("#dLabel span:last-child").toggleClass("select1");
    }, function () {
        $("#myDropdown").removeClass("open");
//      $("#dLabel span:first-child").toggleClass("select");
//      $("#dLabel span:last-child").toggleClass("select1");
    });
    initLogin();
    /*按回车键进行登录*/
//  $(".cymylogin .cyinput2,.cymylogin .cyinput1").bind("keyup", function (evt) {
//      if (evt.keyCode == "13") {
//          $(".cymylogin .cymyloginbutton").trigger("click");
//      }
//  });
    function initLogin() {
        //清空登录
        var cymyLogin = document.getElementsByClassName("cymlogin")[0];
        $("#login").on('shown.bs.modal', function () {
            $(".cymylogin-bottom input").css("border","");
            cymyLogin.style.display = "none";
        });
        RequestService("/online/user/isAlive", "GET", null, function (data) {///online/user/isAlive
            if (data.success === true) {
                var path;
                localStorage.username = data.loginName;
                //头像预览
                if (data.resultObject.smallHeadPhoto != "/home/img/defaultHeadImg.jpg") {
                    path = data.resultObject.smallHeadPhoto;
                } else {
                    path = bath + data.resultObject.smallHeadPhoto
                }
                $(".userPic").css({
                    background: "url(" + path + ") no-repeat",
                    backgroundSize: "100% 100%"
                });
                $('#login').css("display", "none");
                $(".loginGroup .logout").css("display", "none");
                $(".loginGroup .login").css("display", "block");
                $(".dropdown .name").text(data.resultObject.name).attr("title", data.resultObject.name);
                //首页未读消息总数
                RequestService("/online/message/findMessageCount","GET",null,function(data){
                    if(data.success==true && data.resultObject!=0){
                        $(".messageCount").css("display","block");
                        $('#myDropdown').find('.dotRed').css('display','inherit');
                        if(data.resultObject<=99){
                            $(".messageCount em").text(data.resultObject);
                        }else{
                            $(".messageCount em").text(99);
                        }
                    }
                });
                //首页购物车数量
                RequestService("/shoppingCart/findCourseNum","GET",null,function(data){
                    if(data.success==true && data.resultObject!=0){
                        $(".shopping").css("display","block");
                        if(data.resultObject<=99){
                            $(".shopping em").text(data.resultObject);
                        }else{
                            $(".shopping em").text(99);
                        }
                    }
                });
            } else {
                showLoginLable();
            }
        });

        function showLoginLable(){
            $('#login').css("display", "none");
            $(".loginGroup .logout").css("display", "block");
            $(".loginGroup .login").css("display", "none");
        }
        $("#myDropdown a").click(function (evt) {
            $(".top-item").removeClass("selected");
            var btn = $(evt.target);
            var id = "personcenter";
            window.localStorage.personcenter = $(evt.target).attr("data-id");
            if (window.location.pathname == "/web/html/personcenter.html") {
                if ($(this).attr("data-exit")) {
                    RequestService("/online/user/logout", "GET", {}, function () {
                        location.href = "/";
                        $(".loginGroup .logout").css("display", "block");
                        $(".loginGroup .login").css("display", "none");
                    });
                }
                if ($(this).attr("data-post")) {
                    RequestService("/online/user/getBBSUid", "GET", {},function (data) {///online/user/isAlive
                        if (data.success) {
                            location.href = basePathBlog+"/home.php?mod=space&uid="+data.resultObject+"&do=thread&view=me&from=space";
                        }
                    });
                } else {
                    $(".left-nav ." + window.localStorage.personcenter).click();
                }
            } else {
                if ($(this).attr("data-exit")) {
                    RequestService("/online/user/logout", "GET", {}, function () {
                        location.href = "/";
                        $(".loginGroup .logout").css("display", "block");
                        $(".loginGroup .login").css("display", "none");
                    });
                } else if ($(this).attr("data-post")) {
                    RequestService("/online/user/getBBSUid", "GET", {},function (data) {///online/user/isAlive
                        if (data.success) {
                            location.href = basePathBlog+"/home.php?mod=space&uid="+data.resultObject+"&do=thread&view=me&from=space";
                        }
                    });
                } else {
                    location.href = "/web/html/personcenter.html";
                    RequestService("/online/user/isAlive", "GET", null, function (data) {///online/user/isAlive
                        if (data.success) {
                            if (data.resultObject.smallHeadPhoto != "/home/img/defaultHeadImg.jpg") {
                                path = data.resultObject.smallHeadPhoto;
                            } else {
                                path = bath + data.resultObject.smallHeadPhoto
                            }
                            //头像预览
                            $(".userPic").css({
                                background: "url(" + path + ") no-repeat",
                                backgroundSize: "100% 100%"
                            });
                            $('#login').modal('hide');
                            $("html").css({"overflow-x": "hidden", "overflow-y": "auto"});
                            $(".loginGroup .logout").hide();
                            $(".loginGroup .login").show();
                            $(".dropdown .name").text(data.resultObject.name).attr("title", data.resultObject.name);
                            localStorage.username = data.resultObject.loginName;
                            localStorage.userid = data.resultObject.id;
                            if ($(btn.parent().hasClass('selected'))) {

                            } else {
                                hideHtml();
                            }
                        } else {
                            location.href = "/index.html?logout=yes";
                            localStorage.username = null;
                            localStorage.password = null;
                            $(".login").css("display", "none");
                            $(".logout").css("display", "block");
//                          }
                        }
                    });
                }
            }

        });

    }

    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }

    //----在此处判断路径是否包含?logout=yes，如包含则跳转到jsp页面执行bbs退出
    if (getQueryString('logout') === "yes") {
        $("#hidden_frame").attr("src",bath+"/bbsLogout.jsp");
    }else{
        $("#hidden_frame").attr("src",bath+"/bbsLogin.jsp");
    }
    //导航栏搜索框获取焦点
    $('#searchInp').find('input').focus(function(){
        _this=$(this)
        $('.searhInpt').addClass('focus');
        $('.seachBtn').addClass('active');
        $('.searchKeys').hide();
    }).blur(function(){
        if(_this.val()==''){
            $('.searhInpt').removeClass('focus');
            $('.seachBtn').removeClass('active');
            $('.searchKeys').show();
        }
    });
    var schFun=function(keyWords){
        if( keyWords==undefined || keyWords==""){
            $("#searchTxt").focus();
            return
        }else{
            if(window.location.host.indexOf(basePathStudyzone)!=-1){
                window.location.href=bath+"/search/keyword="+keyWords;
            }else{
                var _href=window.location.href;
                sessionStorage.setItem("keyword",keyWords);
                if(_href.indexOf('ask')!='-1'){
                    var type=1
                }else if(_href.indexOf('forum')!='-1'){
                    type=2
                }else{
                    type=0
                }
                sessionStorage.setItem('searchType',type)
                window.location.href=bath+"/search/keyword=" + keyWords;
            }
        }
    };
    //点击搜索
    $('#searchInp').find('button').click(function(){
        schFun($('#searchTxt').val());
    });
    $('.searchKeys span').click(function(){
        var keyWords=$(this).attr('data-keyWords');
        schFun(keyWords);
    })
    //回车搜索
    $('#searchTxt').bind('keyup',function(evt){
        if(evt.keyCode == "13"){
            schFun($('#searchTxt').val());
        }
    });


    var _thisHref=window.location.href;
    $('#sy5').click(function(){
        if(_thisHref.indexOf('login')!=-1){
            window.location=basePathOnline+"/web/html/register.html"
        }else{
            window.location=basePathOnline+"/web/html/register.html?refer="+_thisHref
        }
    })
});